package com.xinghou.platform.file.chain.command.shop;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.chain.Command;
import org.apache.commons.chain.Context;

import com.xinghou.platform.file.model.ResourceContext;
import com.xinghou.platform.file.service.UpphotoService;
import com.xinghou.platform.util.AppContextUtil;
import com.xinghou.platform.util.ConfigUtil;
import com.xinghou.platform.util.StringUtils;

public class PhotoDataProcessCommand implements Command{
	private UpphotoService upphotoService;
	
	@Override
	public boolean execute(Context context) throws Exception {
		@SuppressWarnings("unchecked")
		ResourceContext<byte[], String> resourceContext = (ResourceContext<byte[], String>)context;

		
		Map<String, String> result = new HashMap<String, String>();
		result.put("shopurl", resourceContext.getExtars()[0].getSubPath().replace("\\", "/"));
		result.put("shopname",resourceContext.getSource().getResourceName());
		result.put("userid", resourceContext.getRequest().getUserId());
		result.put("shopid", resourceContext.getRequest().getShopid());
		result.put("imgtype", resourceContext.getRequest().getImgtype());
		//添加商铺图片信息
		int pid=0;
		upphotoService = (UpphotoService)AppContextUtil.getBean("upphotoService");
		pid = upphotoService.addShopPhoto(result);
		context.put("pid", pid);
		return false;
	}


}
